<template>
	<view>
		<map style="width: 100%; height: 500px;" :scale="scale" :latitude="latitude" :longitude="longitude" :markers="covers">
		</map>
		<button @click="MyLocation()">当前位置</button>
		<button @click="CenterLocation()">震中位置</button>
	</view>
</template>

<script>
import AddressUtil from '@/uni_modules/my-getaddress';
export default {
	data() {
		return {
			id:0, // 使用 marker点击事件 需要填写id
			title: 'map',
			showLocation: true,
			scale: 10,
			latitude: 38.909,
			longitude: 106.39742,
			covers: [{
				latitude: 38.909,
				longitude: 106.39742,
				iconPath: '/static/location.png'
			}]
		}
	},
	methods: {
		async MyLocation() {
			let location = await AddressUtil.getAddress();
			this.covers = [{
				latitude: location.latitude,
				longitude: location.longitude,
				iconPath: '/static/location.png'
			}];
			this.latitude = location.latitude;
			this.longitude = location.longitude;
			this.scale = 12
		},
		async CenterLocation() {
			this.covers = [{
				latitude: 38.909,
				longitude: 106.39742,
				iconPath: '/static/location.png'
			}];
			this.latitude = 38.909;
			this.longitude = 106.39742;
			this.scale = 10
		},
	}
}
</script>

<style>

</style>